using Lucy.Engine.Framework.Components;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Lucy.Engine.Framework;

namespace EngineTest
{
    public class EngineTest : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager graphics;
        SpriteBatch _spriteBatch;

        private GameSystem _gameSystem;

        public EngineTest()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
        }

        protected override void LoadContent()
        {
            _spriteBatch = new SpriteBatch(GraphicsDevice);

            _gameSystem = new GameSystem();
            
            GameObject figure = new GameObject();
            figure.Components.Add(new SpriteRendererComponent(Content.Load<Texture2D>("figure")) {Size = new Point(64,64)});
            figure.Components.Add(new MoveComponent());

            _gameSystem.CurrentScene.Layers[0].AddGameObject(figure);
        }

        protected override void Update(GameTime gameTime)
        {
            _gameSystem.Update(gameTime);
            base.Update(gameTime);
        }

        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);
            _spriteBatch.Begin();
            _gameSystem.Render(_spriteBatch);
            _spriteBatch.End();
            base.Draw(gameTime);
        }

        static class Program
        {
            static void Main(string[] args)
            {
                using (EngineTest game = new EngineTest())
                {
                    game.Run();
                }
            }
        }
    }
}
